<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    // 21-04-12 
    //1 如果有多个条件 多 我们可以在数组中存储多个值，并且可以使用数组include方法。
    // 21-05-07 补充 

            //longhand
            if (x === 'abc' || x === 'def' || x === 'ghi' || x ==='jkl') {
            //logic
            }
            //shorthand
            if (['abc', 'def', 'ghi', 'jkl'].includes(x)) {
            //logic
            }


    // 三目 简写 
    

    //给多个变量赋值 
            let test1, test2, test3;
            test1 = 1;
            test2 = 2;
            test3 = 3; 
            let [test1, test2, test3] = [1, 2, 3];
    

    //赋值运算符的简写
            // Longhand
            test1 = test1 + 1;
            test2 = test2 - 1;
            test3 = test3 * 20;
            // Shorthand
            test1++;
            test2--;
            test3 *= 20;        


    //如果存在速记
            // Longhand
            if (test1 === true)
            // Shorthand
            if (test1){}

         
    //Switch速记      
    
    
    //默认参数值
            //Longhand
            function add(test1, test2) {
            if (test1 === undefined)
                test1 = 1;
            if (test2 === undefined)
                test2 = 2;
            return test1 + test2;
            }
            //shorthand
            add = (test1 = 1, test2 = 2) => (test1 + test2);
            add() //output: 3
    

    //点差运算符速记
            //longhand
            //joining arrays using concat
            const data = [1, 2, 3];
            const test = [4 ,5 , 6].concat(data);
            //shorthand
            //joining arrays
            const data = [1, 2, 3];
            const test = [4 ,5 , 6, ...data];
            console.log(test); // [ 4, 5, 6, 1, 2, 3]        


     //随机排列数组中的元素
     var my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9];
        console.log(my_list.sort(function() {
        return Math.random() - 0.5
        })); 
        // [4, 8, 2, 9, 1, 3, 6, 5, 7]

</script>